home *** CD-ROM | disk | FTP | other *** search
/ MacGames Sampler / PHT MacGames Bundle.iso / MacSource Folder / Samples from the CD / Editors / emacs / Emacs-1.14b1-sources / sources / mac-emacs-src / 68k-traps.c next >
Encoding:
C/C++ Source or Header  |  1994-05-20  |  1.3 KB  |  66 lines  |  [TEXT/EMAC]

  1. /*
  2.  * Copyright (C) 1994 Marc Parmet.
  3.  * This file is part of the Macintosh port of GNU Emacs.
  4.  *
  5.  * GNU Emacs is distributed in the hope that it will be useful,
  6.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  7.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  8.  * GNU General Public License for more details.
  9.  */
  10.  
  11. #if defined(THINK_C)
  12. #include <MacHeaders>
  13. #else
  14. #include <Types.h>
  15. #include <Memory.h>
  16. #endif
  17.  
  18. /* This next function is included in its 68k version in both the 68k and PPC versions
  19.    of Emacs.  In the PPC version it comes as a code resource. */
  20.  
  21. void
  22. #if defined(__MWERKS__)
  23. asm
  24. #endif
  25. #if defined(emacs)
  26. execute_68k_trap
  27. #else
  28. main
  29. #endif
  30. (int (*code)(),char *stack_data,int stack_size,struct regs_for_68k_trap *regs)
  31. {
  32. #define code        8(a6)
  33. #define stack_data    12(a6)
  34. #define stack_size    16(a6)
  35. #define regs        20(a6)
  36.  
  37. #if defined(THINK_C)
  38.     asm {
  39. #endif
  40. #if defined(__MWERKS__)
  41.         link    a6,#0
  42. #endif
  43.         move.l    a2,-(a7)
  44.         pea        @epilog
  45.         move.l    stack_size,d0
  46.         move.l    stack_data,a1
  47.         add.l    d0,a1
  48.         asr.l    #1,d0
  49.         bra.s    @test
  50. top:    move.w    -(a1),-(a7)
  51. test:    dbf        d0,@top
  52.         move.l    regs,a2
  53.         movem.l    (a2),d0-d2/a0-a1
  54.         move.l    code,a2
  55.         jmp        (a2)
  56. epilog:    move.l    regs,a2
  57.         movem.l    d0-d2/a0-a1,(a2)
  58.         move.l    (a7)+,a2
  59. #if defined(__MWERKS__)
  60.         unlk    a6
  61. #endif
  62. #if defined(THINK_C)
  63.     }
  64. #endif
  65. }
  66.